#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<queue>
using namespace std;
int t, n, m;
int main()
{
    cin >> t;
    while (t--)
    {
        cin >> m >> n;
        cout << m << " " << n / 2 + 1 << endl;
        priority_queue<int> down;
        priority_queue<int, vector<int>, greater<int> > up;
        int cnt = 0;
        for (int i = 1; i <= n; i++)
        {
            int x;
            cin >> x;
            if (down.empty() || x <= down.top()) down.push(x);
            else up.push(x);
            if (down.size() > up.size() + 1) up.push(down.top()), down.pop();
            if (up.size() > down.size()) down.push(up.top()), up.pop();
            if (i % 2)
            {
                cout << down.top() << " ";
                cnt++;
                if (cnt % 10 == 0) cout << endl;
            }
        }
        if (cnt % 10) cout << endl;
    }
    return 0;
}